import { Button, message, Tag } from "antd";
import cm from "classnames";
import styles from "./index.module.less";
import modal from "antd/es/modal";
import { deleteAddress } from "@/services/address";

const Card = ({ data, onEdit, onDelete, setDefault }) => {
  return (
    <div className={cm(styles.addressCard)}>
      <div className={cm("managerRow", "managerCenter","managerSpread")}>
        <div className={cm("managerRow", "managerCenter", styles.title)}>
          <span className={cm(styles.w120, "managerRow", "managerRight")}>
            收货人：
          </span>
          <span>{data?.recipientName}</span>
          {
            data?.isDefault === 1 &&
          <Tag color="#f50" className={cm(styles.ml10)}>
            默认地址
          </Tag>
          }
        </div>
        <div className={cm("managerRow", "managerCenterH")}>
          {
            data?.isDefault !== 1 &&
          <Button size="small" type="link" onClick={() => setDefault(data)}>设为默认</Button>
          }
          <Button size="small" type="link" onClick={() => onEdit(data)}>编辑</Button>
          <Button size="small" type="link" onClick={() => onDelete(data)}>删除</Button>
        </div>
      </div>
      <div className={cm("managerRow", "managerCenterH", styles.title)}>
        <span className={cm(styles.w120, "managerRow", "managerRight")}>
          所在地区：
        </span>
        <span>{data?.provinceName}{data?.cityName}{data?.regionalName}</span>
      </div>
      <div className={cm("managerRow", "managerCenterH", styles.title)}>
        <span className={cm(styles.w120, "managerRow", "managerRight")}>
          详细地址：
        </span>
        <span>{data?.addressDetails}</span>
      </div>
      <div className={cm("managerRow", "managerCenterH", styles.title)}>
        <span className={cm(styles.w120, "managerRow", "managerRight")}>
          手机号：
        </span>
        <span>{data?.recipientPhone}</span>
      </div>
    </div>
  );
};

export default Card;
